<?
require_once 'config.php';
$keyword = getValue('keyword','str','GET','');
if($keyword == ''){
    redirect('/');
}
$db_all_product = new db_query('SELECT pro_id,pro_name,pro_image,cat_name,cat_id,pro_image,pro_code,pro_price,
                                    MATCH(pro_name) AGAINST("'.$keyword.'" IN BOOLEAN MODE) AS score 
                            FROM products 
                            LEFT JOIN categories_multi ON cat_id = pro_cat_id 
                            WHERE pro_active = 1 
                            AND (MATCH(pro_name) AGAINST("'.$keyword.'" IN BOOLEAN MODE)
                                                OR pro_name LIKE "%'.$keyword.'%") 
                            ORDER BY score DESC, pro_id DESC 
                            LIMIT 9');
$listProducts = $db_all_product->resultArray();unset($db_all_product);
$db_all_news = new db_query('SELECT new_id,new_title,new_picture,cat_name,cat_id,
                                    new_summary,new_date,
                                    MATCH(new_title) AGAINST("'.$keyword.'" IN BOOLEAN MODE) AS score 
                            FROM news 
                            LEFT JOIN categories_multi ON cat_id = new_cat_id 
                            WHERE new_active = 1 
                            AND (MATCH(new_title) AGAINST("'.$keyword.'" IN BOOLEAN MODE)
                                                OR new_title LIKE "%'.$keyword.'%") 
                            ORDER BY score DESC, new_date DESC, new_id DESC 
                            LIMIT 10');
$listNews = $db_all_news->resultArray();unset($db_all_news);
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi" lang="vi" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link type="image/x-icon" href="/favicon.ico" rel="icon" />    
    <title><?=$keyword?> - Tim kiếm | Minh Phú Vinh</title>
    <meta name="description" content="Kết quả tìm kiếm cho từ khóa : <?=$keyword?>"/>
    <meta name="keywords" content=""/>
    <meta name="AUTHOR" content="MinhPhuVinh" />
    <meta name="COPYRIGHT" content="Copyright (C) sudo.vn" />
    <meta name="ROBOTS" content="INDEX, FOLLOW" />
    <meta name="RATING" content="GENERAL" />
    
    <meta property="og:title" content="" />
    <meta property="og:type" content="website" />
    <meta property="og:url" content="" />
    <meta property="og:image" content="" />
    <meta property="og:site_name" content="MassSeo" />
    <meta property="og:description" content="" />
    <meta property="fb:admins" content="100004609203263" />
    <meta property="fb:app_id" content="447585838689244"/> 
    
    <link rel="stylesheet" type="text/css" href="../themes/css/home.css" />	
    <link rel="stylesheet" type="text/css" href="../themes/css/product.css" />	
    <link rel="stylesheet" type="text/css" href="../themes/css/news.css" />	
    <!-- css -->
    <link rel="stylesheet" type="text/css" href="../themes/css/bjqs.css" />
    <link rel="stylesheet" type="text/css" href="../themes/css/jquery.fancybox.css" />
    <!-- js -->
	<script type="text/javascript" src="../themes/js/jquery-1.9.0.min.js"></script>
    <script type="text/javascript" src="../themes/js/bjqs-1.3.min.js"></script>
    <script type="text/javascript" src="../home/js/jquery.fancybox.pack.js"></script>
</head>
<body>
   <div class="wrapper">
      <?
         include('view/common/vic_header.php');
         include('view/common/vic_breadcrumb.php');
         ?>
         <div class="primary">
            <div class="sidebar_wrap">
               <? 
                 include 'view/common/vic_sidebar.php';
               ?>
            </div>
            <div class="news_line_vertical">&nbsp;</div>
            <div class="content_product">
            <?if(count($listProducts) > 0):?>
                <h2>Kết quả tìm kiếm sản phẩm cho từ khóa : <?=$keyword?></h2>
                <div class="content_product_inner">
                <?         
                foreach($listProducts as $row) {
                    ?>
                    <div class="product_cat_item">
                        <a href="<?=generate_product_detail_url($row,$row['cat_name'])?>">
                            <img src="/pictures/products/small_<?=$row['pro_image']?>" alt="<?=$row['pro_name']?>" onerror="this.src='/pictures/no.jpg'" />
                            <div class="product_cat_item_name">
                                <h2><?=$row['pro_name']?></h2>
                            </div>
                        </a>
                    </div>
                    <?
                }  
                ?>
                </div>
            <?else:?>
                <h2>Không tìm thấy sản phẩm nào cho từ khóa : <?=$keyword?></h2>
            <?endif;?> 
            </div><!-- End content -->
            <div class="content_news">
            <?if(count($listNews) > 0):?>
                <h2 style="text-transform: uppercase;">Kết quả tìm kiếm tin tức cho từ khóa : <?=$keyword?></h2>
                <div class="content_news_inner">
                <?
                foreach($listNews as $row) {
                    ?>
                    <div class="news_one">
                       <div class="news_item_img">
                           <img alt="<?=$row['new_title']?>" src="<?=($row['new_picture']) ? news_img.$row['new_picture'] : "/pictures/no.jpg"?>" onerror="this.src='/pictures/no.jpg'" />
                       </div>
                       <div class="news_item_main">
                           <h3><?=cut_string($row['new_title'],70)?></h3>
                           <p class="news_date">Đăng lúc: <?=getDateTime(1,1,1,1,'',$row['new_date'])?></p>
                           <p>&nbsp;&nbsp;&nbsp;<?=cut_string($row['new_summary'],222)?></p>
                           <div class="read_more">
                               <a href="<?=generate_news_detail_url($row)?>">Đọc thêm ...</a>
                           </div>
                       </div>
                  </div>
                    <?
                }
                ?>
                </div>  
                <?else:?>
                    <h2 style="text-transform: uppercase;">Không tìm thấy tin tức nào cho từ khóa : <?=$keyword?></h2>
                <?endif;?>  
                </div><!-- End content -->
            </div><!-- End primary -->
         <?
         include('view/common/vic_heightlight.php');
         include('view/common/vic_footer.php');
      ?>
   </div>
</body>
</html>